// 四个接口
import {getCategoryGoodsCount,getCategoryGoodsSale,getCategoryGoodsFover,getAddressGoodsSale} from '@/service/main/analysis/dashboard'

const dashboardModule={
     namespaced:true,
     state(){
         return{
          categoryGoodsCount:[],
          categoryGoodsSale:[],
          categoryGoodsFavor:[],
          addressGoodsSale:[]
         }
     },
     mutations:{
         changeCategoryGoodsCount(state,list){
             state.categoryGoodsCount=list
         },
         changeCategoryGoodsSale(state,list){
            state.categoryGoodsSale=list
        }, 
        changeCategoryGoodsFavor(state,list){
            state.categoryGoodsFavor=list
        },
        changeAddressGoodsSale(state,list){
            state.addressGoodsSale=list
        }
     },
     actions:{
        async getDashboarDataAction({commit}){
              const categoryCountResult:any=await getCategoryGoodsCount()
              commit('changeCategoryGoodsCount',categoryCountResult.data)

              const categorySaleResult:any=await getCategoryGoodsCount()
              commit('changeCategoryGoodsSale',categorySaleResult.data)

              const categoryFavorResult:any=await getCategoryGoodsCount()
              commit('changeCategoryGoodsFavor',categoryFavorResult.data)

              const addresGoodsResult:any=await getCategoryGoodsCount()
              commit('changeAddressGoodsSale',addresGoodsResult.data)
           }
     }
}

export default dashboardModule